import React from "react";
import ReactDOM from "react-dom";
import {
  BrowserRouter as Router,
  Switch,
  Redirect,
  Route
} from "react-router-dom";

import Login from "page/login/index.jsx";
import Layout from "component/layout/index.jsx";
import Home from "page/home/index.jsx";
import ProductList from 'page/product/router'
import UserList from 'page/user-list/index.jsx'
import ErrorPage from "page/404/error.jsx";

class App extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    let LayoutRouter = (
      <Layout>
        <Switch>
          <Route exact path="/" component={Home} />
          <Route path="/product" component={ProductList} />
          <Route path="/product-category" component={Home} />
          <Route path="/order" component={Home} />
          <Route path="/user/index" component={UserList} />
          <Redirect exact from="/user" to="/user/index" />
          <Route component={ErrorPage} />
          {/* <Redirect from="/404" to="/" /> */}
        </Switch>
      </Layout>
    );
    return (
      <Router>
        <Switch>
          <Route path="/login" component={Login} />
          <Route path="/" render={props => LayoutRouter} />
        </Switch>
      </Router>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("root"));
